package com.kedou.sdk.ui.view;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.kedou.sdk.utils.ResUtils;

/**
 * Created by Administrator on 2017/6/6 0006.
 */

public class ProgressDialog {

    final Builder builder;
    private final Dialog dialog;

    private ProgressDialog(final Builder builder) {
        this.builder = builder;
        this.dialog = builder.progressDialog;
    }

    public void show() {
        if (dialog != null && !dialog.isShowing()) {
            dialog.show();
        }
    }

    public void dismiss() {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
    }

    static class Builder {

        private Context context;
        private View contentView;
        private Dialog progressDialog;


        public Builder(Context context) {
            this.context = context;
            final int layoutResId = ResUtils.getLayoutIdentifier(context, "wan_dialog_progress");
            contentView = LayoutInflater.from(context).inflate(layoutResId, null);
        }

        public ProgressDialog create() {
            progressDialog = new Dialog(context, ResUtils.getStyleIdentifier(context, "hnssn_dialog"));
            progressDialog.setContentView(contentView);
            progressDialog.setCancelable(false);
            progressDialog.setCanceledOnTouchOutside(false);
            return new ProgressDialog(this);
        }

    }


}
